home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / viewkit / xcontact / parody / linklist.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  1.1 KB  |  49 lines

  1. // ------------ linklist.h
  2.  
  3. #ifndef LINKLIST_H
  4. #define LINKLIST_H
  5.  
  6. #include <iostream.h>
  7.  
  8. #ifndef NULL
  9. #define NULL 0
  10. #endif
  11.  
  12. class LinkedListEntry;
  13.  
  14. // ============================
  15. // Linked Listhead
  16. // ============================
  17. class LinkedListHead    {
  18.     friend class LinkedListEntry;
  19.     void *first;
  20.     void *last;
  21. public:
  22.     LinkedListHead() { first = last = NULL; }
  23.     virtual ~LinkedListHead() { /* null */ }
  24.     void *FirstListEntry()    { return first; }
  25.     void *LastListEntry()     { return last; }
  26. };
  27.  
  28. // ============================
  29. // Linked List Entry
  30. // ============================
  31. class LinkedListEntry    {
  32.     LinkedListEntry *prev;
  33.     LinkedListEntry *next;
  34. protected:
  35.     LinkedListHead *listhead;
  36.     LinkedListEntry(LinkedListHead *lh = NULL);
  37.     virtual ~LinkedListEntry() { DeleteListEntry(); }
  38. public:
  39.     void AppendListEntry(LinkedListHead *lh = NULL);
  40.     void PrependListEntry(LinkedListHead *lh = NULL);
  41.     void InsertListEntry(void *fe, LinkedListHead *lh = NULL);
  42.     void DeleteListEntry();
  43.     void *NextListEntry() { return next; }
  44.     void *PrevListEntry() { return prev; }
  45. };
  46.  
  47. #endif
  48.  
  49.